﻿

//仓位转换到easyui tree格式
function gStorageTreeConvert(storages) {
    try {

        var ss = [];
        var count = storages.length;

        for (var i = 0; i < count; i++) {

            var s = storages[i];

            if (!s.IsLeaf) {
                //alert('a :' + s.Name);
                s.children = [];

                for (var j = 0; j < count; j++) {
                    var f = storages[j];
                    if (f.Parent != null && f.Parent.Id == s.Id) {
                        //var c = {};
                        //c.Id = f.Id;
                        //c.Name = f.Name;
                        //c.Number = f.Number;
                        //c.Description = f.Description;
                        //c.NodeLevel = f.NodeLevel;
                        //c.state = "open";
                        f.id = f.Id;
                        f.text = f.Name;
                        f.attributes = {};
                        f.attributes.FullName = f.FullName;
                        s.children.push(f);
                    }
                }
            }
            if (s.NodeLevel == 1) {
                s.id = s.Id;
                s.text = s.Name;
                s.attributes = {};
                s.attributes.FullName = s.FullName;
                ss.push(s);
            }
        }
        return ss;
    } catch (ex) {
        alert(ex);
    }
}

